# views.py
from django.middleware.csrf import get_token
from django.http import JsonResponse

def get_csrf_token(request):
    print("Current CSRF Token:", request.META.get('CSRF_COOKIE'))
    csrf_token = get_token(request)
    print("Generated CSRF Token:", csrf_token)  # 打印生成的 CSRF Token
    print("Current CSRF Token:", request.META.get('CSRF_COOKIE'))
    return JsonResponse({'csrfToken': csrf_token})